package org.mat.ipaas.ucenter.service.api.system;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysRoleDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 角色表 前端控制器
 * </p>
 *
 * @Author scott
 * @since 2018-12-19
 */
@FeignClient(name = "mat-ipaas-ucenter-service",contextId = "sys-role-rest-api")
public interface SysRoleRestAPI {

	/**
	  * 分页列表查询 【系统角色，不做租户隔离】
	 * @param role
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	@RequestMapping(value = "/sys/role/list", method = RequestMethod.GET)
    MatApiResponse<Page<SysRoleDTO>> queryPageList(@SpringQueryMap SysRoleDTO role,
													@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
													@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize);

	/**
	 * 分页列表查询【租户角色，做租户隔离】
	 * @param role
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	@RequestMapping(value = "/sys/role/listByTenant", method = RequestMethod.GET)
    MatApiResponse<Page<SysRoleDTO>> listByTenant(@SpringQueryMap SysRoleDTO role,
												  @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
												  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize);

	/**
	  *   添加
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "/sys/role/add", method = RequestMethod.POST)
    MatApiResponse<SysRoleDTO> add(@RequestBody SysRoleDTO role);

	/**
	  *  编辑
	 * @param role
	 * @return
	 */
	@RequestMapping(value = "/sys/role/edit",method = {RequestMethod.POST})
    MatApiResponse<SysRoleDTO> edit(@RequestBody SysRoleDTO role);

	/**
	  *   通过id删除
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/sys/role/delete", method = RequestMethod.DELETE)
    MatApiResponse<?> delete(@RequestParam(name = "id", required = true) String id);

	/**
	  *  批量删除
	 * @param ids
	 * @return
	 */
	@RequestMapping(value = "/sys/role/deleteBatch", method = RequestMethod.DELETE)
    MatApiResponse<SysRoleDTO> deleteBatch(@RequestParam(name = "ids", required = true) String ids);

	/**
	  * 通过id查询
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/sys/role/queryById", method = RequestMethod.GET)
    MatApiResponse<SysRoleDTO> queryById(@RequestParam(name = "id", required = true) String id);

	/**
	 * 查询全部角色（参与租户隔离）
	 * 
	 * @return
	 */
	@RequestMapping(value = "/sys/role/queryall", method = RequestMethod.GET)
    MatApiResponse<List<SysRoleDTO>> queryall();

	/**
	 * 查询全部系统角色（不做租户隔离）
	 *
	 * @return
	 */
	@RequestMapping(value = "/sys/role/queryallNoByTenant", method = RequestMethod.GET)
    MatApiResponse<List<SysRoleDTO>> queryallNoByTenant();

	/**
	  * 校验角色编码唯一
	 */
	@RequestMapping(value = "/sys/role/checkRoleCode", method = RequestMethod.GET)
    MatApiResponse<Boolean> checkUsername(@RequestParam("id") String id, @RequestParam("roleCode") String roleCode);

	/**
	 * 导出excel
	 * 
	 */
	@RequestMapping(value = "/sys/role/exportXls")
    ModelAndView exportXls(SysRoleDTO sysRole);

	/**
	 * 通过excel导入数据
	 * 
	 * 
	 * @return
	 */
	@RequestMapping(value = "/sys/role/importExcel", method = RequestMethod.POST)
    MatApiResponse<?> importExcel( );

	/**
	 * 查询数据规则数据
	 */
	@GetMapping(value = "/sys/role/datarule/{permissionId}/{roleId}")
    MatApiResponse<?> loadDatarule(@PathVariable("permissionId") String permissionId, @PathVariable("roleId") String roleId);

	/**
	 * 保存数据规则至角色菜单关联表
	 */
	@PostMapping(value = "/sys/role/datarule")
    MatApiResponse<?> saveDatarule(@RequestBody JSONObject jsonObject);


	/**
	 * 用户角色授权功能，查询菜单权限树
	 * 
	 * @return
	 */
	@RequestMapping(value = "/sys/role/queryTreeList", method = RequestMethod.GET)
    MatApiResponse<Map<String,Object>> queryTreeList(@RequestParam HttpServletRequest request);

}
